package lw.badwordsfucker;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;

import java.io.IOException;

public class ParseJSON {
    public static String type;

    public String ripeJSON(String message) throws IOException {
        String json = new RequestAPI().getRawdata(message);
        JSONObject data = JSON.parseObject(json);

        String conclusion = data.getString("conclusionType");
        if (Integer.parseInt(conclusion) != 1){ //如果不是通过，则获取违规类型并赋值给type，并且返回failed
            type = data.getJSONArray("data").getJSONObject(0).getString("subType");
            return "failed";
        } else {
            return "success";
        }
    }
}
